#include <bits/stdc++.h>
// 2025/01/23
// tag: 
// Author: Zhang Muen
using namespace std;

int n;

signed main()
{
    cin >> n;
    int type, len;
    set<int> s;
    for (int i = 1; i <= n; i++)
    {
        cin >> type >> len;
        if (type == 1){
            if (s.find(len) != s.end())
                cout << "Already Exist" << endl;
            else
                s.insert(len);
        }
        else{
            if (s.empty()){
                cout << "Empty" << endl;
                continue;
            }
            if (s.find(len) != s.end()){
                cout << len << endl;
                s.erase(s.find(len));
            }
            else{
                auto p1 = s.lower_bound(len);
                if (p1 == s.begin())
                    cout << *p1, s.erase(p1);
                else if (p1 == s.end())
                    cout << *(--p1), s.erase(p1);
                else if (*p1 - len < len - *(--p1))
                    cout << *(++p1), s.erase(p1);
                else
                    cout << *p1, s.erase(p1);
                cout << endl;
            }
        }
    }
    return 0;
}